package Algoritmos;

public class Utils {

	/**
	 * @param args
	 */
	
	/**
	 * 
	 * @param a Arreglo a imprimir
	 */
	public static void display(int a[]){
		int i,n;
		n=a.length;
		System.out.print("A[] = [");
		for(i=0;i<n;i++)
			System.out.print(a[i]+" ");
		System.out.println("]");
	}
	
	public static void display(double a[]){
		int i,n;
		n=a.length;
		System.out.print("A[] = [");
		for(i=0;i<n;i++)
			System.out.print(a[i]+" ");
		System.out.println("]");
	}
	
	public static void display(long a[]){
		int i,n;
		n=a.length;
		System.out.print("A[] = [");
		for(i=0;i<n;i++)
			System.out.print(a[i]+" ");
		System.out.println("]");
	}

	public static long getMedian(long[] timeCounting) {
		long median=0;
		int i;
		int n=timeCounting.length;
		for(i=0;i<n;++i)
			median+=timeCounting[i];
		return median/n;
	}

	public static double getDesv(long[] timeCounting, long median) {
		long desv=0;
		int i;
		int n=timeCounting.length;
		for(i=0;i<n;++i)
			desv+=Math.pow(timeCounting[i]-median,2);
		return Math.sqrt(desv/(n-1));
	}

}
